<?php
/**
 * AdminUserViewModel.php
 *
* 跨境电商商城系统
 * =============================================
 * Copy right 2016-2026 大连熠泽科技网络有限公司
 * ---------------------------------------------
 * 官方网址: http://www.yizehuitong.com
 * =============================================
 * @author : yizehuitong
 * @date : 2019.10
 * @version : v2.0
 */

namespace data\model;

use data\model\BaseModel as BaseModel;

/**
 * 后台用户view列表
 */
class AdminUserViewModel extends BaseModel
{
	protected $table = 'sys_user_admin';
	
	/**
	 * 获取列表返回数据格式
	 */
	public function getAdminUserViewList($page_index, $page_size, $condition, $order)
	{
		$queryList = $this->getAdminUserViewQuery($page_index, $page_size, $condition, $order);
		$queryCount = $this->getAdminUserViewCount($condition);
		$list = $this->setReturnList($queryList, $queryCount, $page_size);
		return $list;
	}
	
	/**
	 * 获取列表
	 */
	public function getAdminUserViewQuery($page_index, $page_size, $condition, $order)
	{
		$viewObj = $this->alias('sua')
			->join('sys_user sur', 'sur.uid=sua.uid', 'inner')
			->join('sys_user_group su', 'sua.group_id_array=su.group_id', 'left')
			->field('sua.uid, sur.user_name as admin_name, sua.is_admin, sur.user_status, su.group_name, sur.user_headimg, sur.user_email, sur.user_tel');
		$list = $this->viewPageQuery($viewObj, $page_index, $page_size, $condition, $order);
		return $list;
	}
	
	/**
	 * 获取列表数量
	 */
	public function getAdminUserViewCount($condition)
	{
		$viewObj = $this->alias('sua')
			->join('sys_user sur', 'sur.uid=sua.uid', 'inner')
			->join('sys_user_group su', 'sua.group_id_array=su.group_id', 'left')
			->field('sua.ua_id');
		$count = $this->viewCount($viewObj, $condition);
		return $count;
	}
	
}